home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PsL Monthly 1993 December
/
PSL Monthly Shareware CD-ROM (December 1993).iso
/
prgmming
/
dos
/
c
/
cmprss.exe
/
CP.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1993-01-26
|
1KB
|
79 lines
#include <iostream.h>
#include "compress.cls"
#include "decpress.cls"
main(int argc, char *argv[])
{
if (argc!=4)
{
cout<< "Usage: cp <c | d> <file in> <file out>\n";
return 1;
}
switch (argv[1][0])
{
case 'c':
case 'C':
{
ifstream fi(argv[2],ios::in | ios::binary);
if (fi.bad())
{
cout<<"Can't open input file\n";
return 1;
}
fi.flags(0); // clear \n translation
cpofstream fo(argv[3]);
if (fo.bad())
{
cout<<"Can't open output file\n";
return 1;
}
char c;
for (;;)
{
fi>>c;
if (fi.eof())
break;
fo<<c;
}
fi.close();
fo.close();
break;
}
case 'd':
case 'D':
{
cpifstream fi(argv[2]);
if (fi.bad())
{
cout<<"Can't open input file\n";
return 1;
}
ofstream fo(argv[3],ios::out | ios::binary);
if (fo.bad())
{
cout<<"Can't open output file\n";
return 1;
}
char c;
for (;;)
{
fi>>c;
if (fi.done()) // can't use EOF on binary files ???
break;
fo<<c;
}
fi.close();
fo.close();
break;
}
default:
cout<< "Usage: cp <c | d> <file in> <file out>\n";
return 1;
}
return 0;
}